home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 49 / Amiga Format CD49 (2000-01-17)(Future Publishing)(GB)(Track 1 of 3)[!][issue 2000-02].iso / -serious- / misc / football / exec / games.rexx < prev    next >
OS/2 REXX Batch file  |  1999-11-29  |  12KB  |  352 lines

  1. /* ***********************************************************************
  2.  
  3.    GAMES PROGRAM FOR FOOTBALL REXX SUITE
  4.   -------------------------------------------
  5.                    Copyright  Mark Naughton 1996
  6.  
  7.  
  8. Version    Date     History
  9. --------------------------------------------------------------------------
  10.  1.0       230996   First release. Finished putting in code to display
  11.                     fixtures. Started 17/09/96. Added whether its a WIN,
  12.                     a DRAW or LOST to output. Added error check in case
  13.                     the selected team was incorrect.
  14.            270996   Updated to use new filenames. Improved error messages.
  15.            300996   Tidied code slightly. Added error message.
  16.  1.1       111196   Updated to use different leagues and to become a
  17.                     component called by FOOTBALL. Changed to read info
  18.                     from '*.sflearn' as this data is in the correct order.
  19.                     Gets team name from argument.
  20.            131196   Added checks for files - if not found, exits without
  21.                     a message.
  22.            211196   Updated and tidied the display.
  23.            190497   Added title to display.
  24.  1.2       150997   Added code to handle dates/weeks from Automatic-
  25.                     Scheduling. Tidied display and added headings.
  26.            151297   Tidied display.
  27.            050599   Amended display.
  28.            250899   Added error msg to file checks.
  29.            270899   Converted to use locale. Some error messages, before
  30.                     reading the locale, will still be in English.
  31.            010999   Converted to use a global date format file. Now correctly
  32.                     translates date format to get required data.
  33.            050999   Found a problem where if the datafile was created with
  34.                     a different locale, you wouldn't be able to read it so
  35.                     now we read through the control files for all locales
  36.                     making sure we find the correct date data.
  37.  
  38. **************************************************************************
  39.  
  40. Procedure
  41. ---------
  42.  
  43. 1. Check files exist. Read Teams.df datafile and store teams.
  44. 2. Search for specified team and if not found, give an error and quit.
  45. 3. Open datafile depending whether it was autoscheduled or not.
  46. 4. If "Week" or "Date" is found, grab the data and format it for later.
  47. 5. Use selected team against either HOME or AWAY team and if a match is
  48.    found then display the data.
  49. 6. When the file is finished, print the number of matches and exit...
  50.  
  51. ************************************************************************** */
  52. PARSE ARG league_stuff
  53.  
  54. version      = 1
  55. input_file   = '.df'
  56. input2_file  = '.sflearn'
  57. input3_file  = '.sf'
  58. title        = '*LEAGUE_NAME='
  59. autosched    = '*AUTOSCHD='
  60. separator    = '*'
  61. teams.       = '???'
  62. counter      = 0
  63. not_played   = '__   __'
  64.  
  65.  
  66. parse var league_stuff league_file search_team
  67. league_file = "Data/" || league_file
  68.  
  69.  
  70. if open(datafile,"Data/Football.locale",'r') then do
  71.    line = readln(datafile)
  72.    locdir = strip(line)
  73.    close(datafile)
  74. end
  75. else do
  76.    say
  77.    say "ERROR :    (Games)"
  78.    say
  79.    say "Cannot read 'Data/Football.locale' for the locale settings."
  80.    exit
  81. end
  82.  
  83. dfordir = locdir"Football.locale_data"
  84. locdir = locdir"Exec/Games.data"
  85.  
  86. if open(datafile,"ENV:FootballRXPath",'r') then do
  87.    line = readln(datafile)
  88.    rxdir = strip(line)
  89.    close(datafile)
  90. end
  91. else
  92.    rxdir = "SYS:Rexxc/"
  93.  
  94. if exists(locdir) > 0 then do
  95.   address command rxdir'rx 'locdir
  96.   VarCount = getclip('VarCount')
  97.   do i = 1 to VarCount
  98.     interpret getclip('var.'i)
  99.   end
  100. end
  101. else do
  102.    say
  103.    say "ERROR :    (Games)"
  104.    say
  105.    say "Cannot find '"locdir"' to read locale settings."
  106.    exit
  107. end
  108.  
  109. if exists(dfordir) > 0 then do
  110.   address command rxdir'rx 'dfordir
  111.   VarCount = getclip('VarCount')
  112.   do i = 1 to VarCount
  113.     interpret getclip('var.'i)
  114.   end
  115. end
  116. else do
  117.    say
  118.    say "ERROR :    (Games)"
  119.    say
  120.    say "Cannot find '"dfordir"' to read date locale settings."
  121.    exit
  122. end
  123.  
  124. if exists(league_file || input_file) = 0  then do
  125.    say
  126.    say gm_error
  127.    say
  128.    say gm_one"'"league_file||input_file"'."
  129.    exit
  130. end
  131.  
  132. if exists(league_file || input2_file) = 0 then do
  133.    say
  134.    say gm_error
  135.    say
  136.    say gm_one"'"league_file||input2_file"'."
  137.    exit
  138. end
  139.  
  140. if exists(league_file || input3_file) = 0 then do
  141.    say
  142.    say gm_error
  143.    say
  144.    say gm_one"'"league_file||input3_file"'."
  145.    exit
  146. end
  147.  
  148. autos = 0
  149. if open(datafile,league_file || input_file,'r') then do
  150.    do while ~eof(datafile)
  151.       line = readln(datafile)
  152.       if pos(title,line) > 0 then
  153.          league_title = delstr(line,1,13)
  154.       if pos(autosched,line) > 0 then
  155.          autos = 1
  156.       if pos(separator,line) = 0 then do
  157.          line = strip(line)
  158.          if counter = 0 then do
  159.             teams.1 = line
  160.             counter = 1
  161.          end
  162.          else do
  163.             counter       = counter + 1
  164.             teams.counter = line
  165.          end
  166.       end
  167.    end
  168.    close(datafile)
  169.  
  170.    sel=-1
  171.    search_team = strip(search_team)
  172.    do i=1 to counter
  173.       if pos(search_team,teams.i) > 0 then
  174.          sel = i
  175.    end
  176.    if sel > 0 then do
  177.       say
  178.       say center(gm_two"'"league_title"'",78)
  179.       say "-------------------------------------------------------------------------------"
  180.       say
  181.       say gm_three""teams.sel
  182.       say gm_four
  183.       say
  184.       matches = 0
  185.       if autos = 1 then do
  186.          file_to_open = league_file || input3_file
  187.          say gm_five
  188.          say "-----------------------------------------------------------------------------"
  189.       end
  190.       else do
  191.          file_to_open = league_file || input2_file
  192.          say gm_six
  193.          say "-----------------------------------------------------------------------------"
  194.       end
  195.       if open(datafile,file_to_open,'r') then do
  196.          do while ~eof(datafile)
  197.             line = readln(datafile)
  198.             if autos = 1 then do
  199.                if pos(separator,line) > 0 then do
  200.                   if pos("*Week:",line) > 0 then do
  201.                      curr = subword(line,2)
  202.                   end
  203.                   s_l = 0
  204.                   if pos("*Date:",line) > 0 then do
  205.                      if s_l = 0 then do
  206.                         parse var line "*Date:" dateall
  207.                         search_loc = strip(word(dateall,words(dateall)-1))
  208.                         do mnls=1 to 12
  209.                            if pos(word(months,mnls),search_loc) > 0 then do
  210.                               s_l = 1
  211.                               leave
  212.                            end
  213.                         end
  214.                         if s_l = 0 then do
  215.                            locale_cats = showdir("Locale/")
  216.                            do search_locale=1 to words(locale_cats)
  217.                               dfordir = "Locale/"word(locale_cats,search_locale)"/Football.locale_data"
  218.                               if exists(dfordir) > 0 then do
  219.                                 address command rxdir'rx 'dfordir
  220.                                 VarCount = getclip('VarCount')
  221.                                 do i = 1 to VarCount
  222.                                   interpret getclip('var.'i)
  223.                                 end
  224.                               end
  225.                               parse var line "*Date:" dateall
  226.                               search_loc = strip(word(dateall,words(dateall)-1))
  227.                               do mnls=1 to 12
  228.                                  if pos(word(months,mnls),search_loc) > 0 then do
  229.                                     s_l = 1
  230.                                     leave
  231.                                  end
  232.                               end
  233.                               if s_l = 1 then leave
  234.                            end
  235.                         end
  236.                         if s_l > 0 then do
  237.                            temp_dtal = dateall
  238.                            parse var date_format "day" sp1 "number" sp2 "month" sp3 "year"
  239.                            parse var line "*Date:" dateall
  240.                            do i=1 to 7
  241.                               if pos(word(days,i),dateall) > 0 then do
  242.                                  lk = pos(word(days,i),dateall)
  243.                                  dateall = delstr(dateall,1,lk+length(word(days,i))+length(sp1)-1)
  244.                               end
  245.                            end
  246.                            dateall = strip(dateall)
  247.                            year = word(dateall,words(dateall))
  248.                            mnth = strip(word(dateall,words(dateall)-1))
  249.                            do lm=1 to length(mnth)
  250.                               if datatype(substr(mnth,1,1),'m') ~= 1 then
  251.                                  mnth = delstr(mnth,1,1)
  252.                            end
  253.                            mnth = substr(mnth,1,3)
  254.                            dateall = temp_dtal
  255.                            day  = word(dateall,2)
  256.                            do lm=1 to length(day)-2
  257.                               if datatype(substr(day,3,1),'n') ~= 1 then
  258.                                  day = delstr(day,3,1)
  259.                            end
  260.                            cv = 0
  261.                            do i=1 to 12
  262.                               if pos(word(months,i),mnth) > 0 then do
  263.                                  cv = i
  264.                                  leave
  265.                               end
  266.                            end
  267.                         end
  268.                      end
  269.                      if s_l = 0 then do
  270.                         say
  271.                         say ma_t1
  272.                         say
  273.                         say ma_t11
  274.                         exit
  275.                      end
  276.                      curr = right(day,2,0)" "mnth" "substr(year,3,2)
  277.                   end
  278.                end
  279.             end
  280.             else
  281.                curr = ''
  282.             if pos(separator,line) = 0 then do
  283.                if pos(not_played,line) = 0 then do
  284.                   home_team = strip(substr(line,1,30))
  285.                   goals_for = substr(line,32,2)
  286.                   goals_aga = substr(line,37,2)
  287.                   away_team = strip(substr(line,41,30))
  288.  
  289.                   strng = strip(teams.sel)
  290.                   if strng = home_team then do
  291.                      if goals_for > goals_aga then
  292.                         ttemp = gm_fourteen
  293.                      if goals_for = goals_aga then
  294.                         ttemp = gm_fifteen
  295.                      if goals_for < goals_aga then
  296.                         ttemp = gm_sixteen
  297.                      if autos = 1 then
  298.                         say left(curr,15)""gm_seven""left(away_team,30)" "goals_for" -"goals_aga" "right(ttemp,12)
  299.                      else
  300.                         say gm_seven""left(away_team,30)" "goals_for" -"goals_aga" "right(ttemp,12)
  301.                      matches = matches + 1
  302.                   end
  303.                   if strng = away_team then do
  304.                      if goals_for > goals_aga then
  305.                         ttemp = gm_sixteen
  306.                      if goals_for = goals_aga then
  307.                         ttemp = gm_fifteen
  308.                      if goals_for < goals_aga then
  309.                         ttemp = gm_seventeen
  310.                      if autos = 1 then
  311.                         say left(curr,15)""gm_eight""left(home_team,30)" "goals_aga" -"goals_for" "right(ttemp,12)
  312.                      else
  313.                         say gm_eight""left(home_team,30)" "goals_aga" -"goals_for" "right(ttemp,12)
  314.                      matches = matches + 1
  315.                   end
  316.                end
  317.             end
  318.          end
  319.          close(datafile)
  320.          say
  321.          if matches = 0 then
  322.             say gm_nine
  323.          else
  324.             say gm_ten""matches
  325.          say
  326.          say "-------------------------------------------------------------------------------"
  327.          say
  328.       end
  329.       else do
  330.          say
  331.          say gm_error
  332.          say
  333.          say gm_eleven"'"league_file || input2_file"'."
  334.          exit
  335.       end
  336.    end
  337.    else do
  338.       say
  339.       say gm_error
  340.       say
  341.       say gm_twelve"'"search_team"'"gm_thirteen
  342.       exit
  343.    end
  344. end
  345. else do
  346.    say
  347.    say gm_error
  348.    say
  349.    say gm_eleven"'"league_file || input_file"'."
  350. end
  351.  
  352. exit